package com.face.console.dao;

import com.face.console.pojo.dto.UserDto;
import com.face.console.pojo.query.UserQuery;
import com.face.console.pojo.vo.UserVo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface UserDtoMapper {
    @Delete({
            "delete from face_user",
            "where id = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    @Insert({
            "insert into face_user (id, username, ",
            "password)",
            "values (#{id,jdbcType=BIGINT}, #{username,jdbcType=VARCHAR}, ",
            "#{password,jdbcType=VARCHAR})"
    })
    int insert(UserDto record);

    int insertSelective(UserDto record);

    @Select({
            "select",
            "id, username, password",
            "from face_user",
            "where id = #{id,jdbcType=BIGINT}"
    })
//    @ResultMap("com.face.console.dao.UserDtoMapper.BaseResultMap")
    UserDto selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(UserDto record);

    @Update({
            "update face_user",
            "set username = #{username,jdbcType=VARCHAR},",
            "password = #{password,jdbcType=VARCHAR}",
            "where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(UserDto record);

    @Select({"select u.id,u.username,u.password from face_user u"})
    List<UserDto> selectUserAll();

    @Select({"select",
            "id,username,password",
            "from face_user",
            "where username = #{username} and password = #{password}"})
    UserVo login(UserQuery query);
}